package com.mzx.javase.io;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

/**
 * 类描述：使用fileReader读取windows中文
 *
 * @ClassName FileReaderTest02
 * @Description TODO
 * @Author 马子鑫
 * @Date 2022/7/31 17:18
 * @Version 1.0
 */
public class FileReaderTest02 {
    public static void main(String[] args) {
        FileReader fileReader = null;
        try {
            fileReader = new FileReader("D:\\java\\tempdirectory\\test02.txt");
            int read = 0;
            while ((read = fileReader.read()) != -1) {
                System.out.println((char)read);
            }
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }finally {
            if (fileReader != null) {
                try {
                    fileReader.close();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        }
    }
}
